<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Site
 *
 * @author ZangGuoPing
 */
class Site extends CActiveRecord {
    private $row;
    public function rules() {
        return array(
            array('site_auth_play,site_name,site_title,site_domain,site_save_log_day,
                site_keeplive,site_datezone,site_run_status,site_comment_status,site_description,site_keywords', 'required', 'on' => 'default'),
            array('site_domain', 'url'),
            array('site_mailserver_port,site_video_money,site_user_money', 'numerical'),
            array('site_user_register,site_user_money,site_user_level,site_user_days,
                site_user_hidden_level,site_mailserver_host,site_mailserver_port,
                site_mailserver_username,site_mailserver_password,site_mailserver_sender', 'required', 'on' => 'user'),
            array('site_video_window,site_video_server,site_video_player,site_video_region,
                site_video_pic,site_video_level,site_video_play,site_video_down,site_video_money,site_video_quality', 'required', 'on' => 'video')
        );
    }

    public function attributeLabels() {
        return array(
            'title' => Yii::t('default', '网站配置'),
            'site_name' => Yii::t('default', '网站名称'),
            'site_title' => Yii::t('default', '网站标题'),
            'site_keywords' => Yii::t('default', '关键词'),
            'site_description' => Yii::t('default', '网站描述'),
            'site_video_quality' => Yii::t('default', '视频画质'),
            'site_dialog' => Yii::t('default', '视频对白'),
            'site_domain' => Yii::t('default', '网站域名'),
            'site_keeplive' => Yii::t('default', '在线监测频率'),
            'site_save_log_day' => Yii::t('default', '日志保存时间'),
            'site_run_status' => Yii::t('default', '系统运行状态'),
            'site_datezone' => Yii::t('default', '服务器时区'),
            'site_comment_status' => Yii::t('default', '系统评论'),
             'site_auth_play' => Yii::t('default', '站点权限设置'),
            'site_video_player' => Yii::t('default', '默认视频播放器'),
            'site_video_region' => Yii::t('default', '默认视频地区'),
            'site_video_pic' => Yii::t('default', '默认视频海报'),
            'site_video_level' => Yii::t('default', '默认视频点播组'),
            'site_video_server' => Yii::t('default', '默认视频服务器'),
            'site_video_play' => Yii::t('default', '默认点播'),
            'site_video_down' => Yii::t('default', '默认下载'),
            'site_video_money' => Yii::t('default', '默认视频价格'),
            'site_user_register' => Yii::t('default', '用户注册'),
            'site_user_money' => Yii::t('default', '初始用户虚拟币'),
            'site_user_level' => Yii::t('default', '初始用户等级'),
            'site_video_window' => Yii::t('default', '视频窗口模式'),
             'site_user_hidden_level' => Yii::t('default', '隐藏此权限视频'),
            'site_user_days' => Yii::t('default', '初始用户观看天数'),
            'site_mailserver_host' => Yii::t('default', '邮件服务器主机名'),
            'site_mailserver_port' => Yii::t('default', '邮件服务器端口'),
            'site_mailserver_sender' => Yii::t('default', '发件人邮件地址'),
            'site_mailserver_username' => Yii::t('default', '邮件服务器帐户名'),
            'site_mailserver_password' => Yii::t('default', '邮件服务器帐户密码')
            
        );
    }

    /**
     * Returns the static model of the specified AR class.
     * @return CActiveRecord the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return '{{site}}';
    }
    public function getConfig($key){
        if(!$this->row){
            $this->row = $this->find();
        }
        return $this->row[$key];
    }
    public function getRunDataList() {
        $data = array(Yii::t('default', '维护中'), Yii::t('default', '运行中'));
        return $data;
    }

    public function getSaveLogDataList() {
        return array('0' => '关闭', '1' => '一天', '7' => '一周', '30' => '一个月', '99999999' => '永久保存');
    }

    public function getKeepliveDataList() {
        return array('0' => '关闭', '5' => '5s', '10' => '10s', '30' => '30s', '60' => '1m', '600' > '10m', '1800' => '30m');
    }

    public function getCommentDataList() {
        return array('关闭评论', '需要登录', '登录并且需要审核');
    }
    public function getVideoWindowList(){
        return array('弹出窗口', '新开窗口');
    }
    public function getPlayAuthList(){
        return array('默认模式', '不登录免费看', '登录后免费');
    }
    public function getPlayerList() {
        $data = Player::model()->findAll();
        return CHtml::listData($data, 'player_alias', 'player_name');
    }

    public function getRegionList() {
        $video = new Video();
        return $video->getRegionArray();
    }
    public function getQualityList(){;
     $video = new Video();
        return $video->getQualityData();
    }
    public function getServerList() {
        $data = Server::model()->findAll();
        return CHtml::listData($data, 'server_id', 'server_name');
    }

    public function getVideoLevel() {
        $models = UserGroup::model()->findAll();
        return CHtml::listData($models, 'usergroup_level', 'usergroup_name');
    }

    public function getPlayList() {
        return array('关闭', '开放');
    }

}

?>
